<template>
  <div
    v-loading="loading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.8)"
  >
    <el-upload
      class="upload-demo"
      drag
      action="http://119.23.217.208:8081/upload"
      :on-preview="handlePreview"
      :on-remove="handleRemove"
      :on-success="handlSuccess"
      :on-error="handlError"
      :on-change="handlChange"
      :file-list="fileList"
      list-type="picture">
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      <div slot="tip" class="el-upload__tip">只能上传不超过500kb的文件</div>
    </el-upload>
    <el-divider><i class="el-icon-loading"></i></el-divider>
    <el-button
      type="primary" icon="el-icon-refresh-left" @click="updateExcel">发布</el-button>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    data() {
      return {
        loading:false,
        fileList: [],
      };
    },
    methods: {
      updateExcel(){
        this.loading = true
        axios.get("/hallupdateexcel").then(resp => {
            if(resp.data.result){
              alert(resp.data.msg)
            }else {
              alert(resp.data.error)
            }
          this.loading = false;
        }).catch(err => {
          this.loading = false;
          alert(err)
        })
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file,'Preview++++++++');
      },
      handlSuccess(response){
        if(response.result){
          alert(response.msg)
        }else {
          this.fileList = []
          alert(response.error)

        }
      },
      handlError(err, file, fileList){
        console.log(err,file, fileList,'error++++++++');
      },
      handlChange(file, fileList){
        console.log(file, fileList,'Change++++++++');
      },
    }
  }
</script>

<style scoped>

</style>
